package com.genius.adminmanager.group.service.impl;


import java.sql.SQLException;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.group.entity.GroupEntity;
import com.genius.adminmanager.group.service.GroupServiceAdapter;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.workflow.util.ConnectionException;
import com.genius.workflow.util.DBClosedException;
import com.genius.workflow.util.TreeUtils;

@Service("groupDeleteService")
public class GroupDeleteServiceImpl extends GroupServiceAdapter{

	@Override
	public JSONObject batchdel(JSONObject json, JSONObject response) {
		
		try {
			String table = "t_group";
			response.put(ResponseJson.status, ResponseJson.status_Success);
			TreeUtils.delByIdTree(table, GroupEntity.groupId, GroupEntity.pId,json );
			response.put(ResponseJson.msg, "删除组织机构成功");
		} catch (ConnectionException e) {
			response.put(ResponseJson.status, ResponseJson.status_Failed);
    		response.put(ResponseJson.msg, ResponseJson.msg_DB_Connect_Failed);
		} catch (DBClosedException e) {
			response.put(ResponseJson.status, ResponseJson.status_Failed);
			response.put(ResponseJson.msg, ResponseJson.msg_DB_Closed_Failed);
		} catch (SQLException e) {
			response.put(ResponseJson.status, ResponseJson.status_Failed);
			response.put(ResponseJson.msg, ResponseJson.msg_Del_Data_Error);
		}
		
		return response;
	}

	
}
